#include "loghandler.h"

using namespace std;
using namespace spacedefender;

Loghandler Loghandler::_loghandler;

Loghandler::Loghandler()
{
	_lastMsg = "";
	_log = new list<string>();
}

Loghandler::~Loghandler()
{
	if(_log)
	{
		_log->clear();
		
		delete _log;
		_log = 0;
		
	}
	
	_lastMsg = "";
}

Loghandler* Loghandler::GetInstance()
{
	return &_loghandler; 
}

void Loghandler::Log(string msg)
{
	_lastMsg = msg;
	_log->push_back(msg);
	
	this->Notify();
}

list<string>* Loghandler::GetLog() const
{
	return _log;
}

string Loghandler::GetLatestLogText() const
{
	return _lastMsg;
}